package com.sbeisenov.students.common.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sbeisenov.students.common.model.HelloWorldModel;
import com.sbeisenov.students.common.service.HelloWorldService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class HelloWorldController extends AbstractController{

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
                                                 HttpServletResponse response) throws Exception {

        HelloWorldService service = new HelloWorldService();
        HelloWorldModel data = service.getHelloWorldData();

        ModelAndView model = new ModelAndView("HelloWorldPage");

        model.addObject("msg", "hello world");
        model.addObject("data", data);

        return model;
    }
}
